<template>
  <div>
    <form>
      <label>姓名：</label>
      <input type="text" v-model="msg" /><br /><br />

      <label>年龄：</label>
      <input type="number" v-model.number="age" /><br /><br />

      <label>身高：</label>
      <input type="number" v-model.number="high" />(米)<br /><br />

      <label>体重：</label>
      <input type="number" v-model.number="wei" />(公斤)<br /><br />

      <label>病史：</label>
      <input type="text" v-model="die" /><br /><br />

      <button @click.prevent="sum(wei, high)">诊断</button>
    </form>

    <p v-show="isShow">患者{{msg}} 的诊断结果：{{diagnosis}}</p>
  </div>
</template>

<script>
export default {
  data() {
    return {
      isShow: false,
      msg: "",
      age: "",
      high: "",
      wei: "",
      die: "",
      diagnosis: "",
    };
  },
  methods: {
    sum(w, h) {
      console.log(w,h);
      let BMI = w/(h*h)
      if (BMI < 18.5 ) {
        this.diagnosis = '体重过轻'
      }else if(BMI >= 18.5 && BMI <24.9){
        this.diagnosis = '正常'
      }else if (BMI >= 24.9 && BMI < 29.9){
       this.diagnosis = '体重过重'
      }else {
        this.diagnosis = '肥胖'
      }
      this.isShow = true
    },
  },
};
</script>
